<template>
  <div class="page-container">
    <!-- 导航栏 -->
    <nav class="navbar" :class="{ 'navbar-scrolled': isScrolled }">
      <div class="nav-brand">韶华胜极</div>
      <div class="nav-links" :class="{ 'nav-active': isMenuOpen }">
        <a href="#" class="nav-item active">首页</a>
        <a href="#intro" class="nav-item">汉服介绍</a>
        <a href="#style" class="nav-item">汉服搭配</a>
        <a href="#contact" class="nav-item">联系我们</a>
      </div>
      <div class="user-center">
        <a href="/profile" class="nav-item">个人中心</a>
      </div>
    </nav>

    <!-- 主要内容区 -->
    <div class="main-content">
      <!-- 左侧文字内容 -->
      <div class="text-section">
        <div class="text-content">
          <h1 class="main-title">传统之美</h1>
          <div class="subtitle">汉服文化</div>
          <div class="description">
            <p class="elegant-text">
              汉服，是中国传统服饰的统称，承载着深厚的文化底蕴和历史价值。
              每一套汉服都蕴含着独特的设计理念和工艺技巧，展现着中国传统美学的精髓。
            </p>
          </div>
          <button class="explore-button" @click="goToLogin">
            <span class="button-text">探寻华服之韵</span>
          </button>
        </div>
      </div>

      <!-- 右侧图片展示 -->
      <div class="image-section">
        <div class="carousel-container">
          <transition-group name="fade">
            <img 
              v-for="(image, index) in images" 
              :key="index"
              :src="image"
              v-show="currentImageIndex === index"
              class="carousel-image"
              alt="汉服展示"
            >
          </transition-group>
          
          <div class="carousel-controls">
            <button class="carousel-btn prev" @click="prevImage">
              <i class="fas fa-chevron-left"></i>
            </button>
            <button class="carousel-btn next" @click="nextImage">
              <i class="fas fa-chevron-right"></i>
            </button>
          </div>
          
          <div class="carousel-indicators">
            <span 
              v-for="(_, index) in images" 
              :key="index"
              :class="{ active: currentImageIndex === index }"
              @click="setImage(index)"
              class="indicator-dot"
            ></span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.page-container {
  min-height: 100vh;
  background: #f9f4e9;
  position: relative;
  overflow-x: hidden;
}

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 3rem;
  background: rgba(249, 244, 233, 0.98);
  backdrop-filter: blur(10px);
  z-index: 1000;
  border-bottom: 1px solid rgba(166, 123, 91, 0.2);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  height: 90px;
}

.nav-brand {
  font-size: 32px;
  font-weight: 800;
  color: #6b4423;
  font-family: "FangSong", serif;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.nav-links {
  display: flex;
  gap: 4rem;
}

.nav-item {
  color: #6b4423;
  text-decoration: none;
  font-size: 20px;
  font-weight: 600;
  font-family: "FangSong", serif;
  position: relative;
  padding: 0.5rem 0;
  transition: color 0.3s ease;
}

.nav-item.active {
  color: #4a2e17;
  font-weight: 700;
}

.nav-item::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: #6b4423;
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.nav-item:hover {
  color: #4a2e17;
}

.nav-item:hover::after {
  transform: scaleX(1);
}

.user-center {
  display: flex;
  align-items: center;
  margin-left: 2rem;
  margin-right: 1rem;
}

.user-center .nav-item {
  color: #6b4423;
  text-decoration: none;
  font-size: 20px;
  font-weight: 600;
  font-family: "FangSong", serif;
  padding: 0.6rem 2rem;
  border: 2px solid #6b4423;
  border-radius: 24px;
  transition: all 0.3s ease;
  white-space: nowrap;
  height: auto;
  line-height: normal;
  display: inline-block;
  text-align: center;
  min-width: 120px;
  position: relative;
  top: 0;
}

.user-center .nav-item:hover {
  background: #6b4423;
  color: #fff;
}

.main-content {
  display: flex;
  height: 100vh;
  width: 100%;
  padding-top: 90px;
}

.text-section {
  width: 40%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: #f9f4e9;
}

.text-content {
  max-width: 600px;
  padding: 2rem;
}

.main-title {
  font-size: 48px;
  color: #8b5e3c;
  margin-bottom: 1rem;
  font-family: "FangSong", serif;
}

.subtitle {
  font-size: 28px;
  color: #a67b5b;
  margin-bottom: 2rem;
  font-family: "FangSong", serif;
}

.description {
  margin-bottom: 2rem;
}

.elegant-text {
  font-size: 18px;
  line-height: 1.8;
  color: #5c4030;
  font-family: "FangSong", serif;
}

.image-section {
  width: 60%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.carousel-container {
  width: 100%;
  height: 100%;
  position: relative;
  background: #2c1810;
}

.carousel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
}

.carousel-controls {
  position: absolute;
  top: 50%;
  width: 100%;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 2rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.carousel-container:hover .carousel-controls {
  opacity: 1;
}

.carousel-btn {
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.3s ease;
}

.carousel-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.carousel-indicators {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1rem;
}

.indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.3s ease;
}

.indicator-dot.active {
  background: #fff;
  transform: scale(1.2);
}

.explore-button {
  padding: 1rem 3rem;
  font-size: 20px;
  color: #fff;
  background: #8b5e3c;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: "FangSong", serif;
  letter-spacing: 4px;
}

.explore-button:hover {
  background: #a67b5b;
  transform: translateY(-2px);
}

/* 动画效果 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
  }

  .text-section,
  .image-section {
    width: 100%;
    height: 50vh;
  }

  .text-content {
    text-align: center;
    padding: 1rem;
  }

  .main-title {
    font-size: 36px;
  }

  .subtitle {
    font-size: 24px;
  }

  .elegant-text {
    font-size: 16px;
  }

  .navbar {
    padding: 1rem 2rem;
  }

  .nav-brand {
    font-size: 28px;
  }

  .nav-item {
    font-size: 18px;
  }

  .nav-links {
    gap: 2rem;
  }
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
  }

  .user-center {
    display: none;
  }
}
</style>

<script>
export default {
  name: 'HomePage',
  data() {
    return {
      images: [
        new URL('../assets/images/hanfu1.jpg', import.meta.url).href,
        new URL('../assets/images/hanfu2.jpg', import.meta.url).href,
        new URL('../assets/images/hanfu3.jpg', import.meta.url).href,
        new URL('../assets/images/hanfu4.jpg', import.meta.url).href,
        new URL('../assets/images/hanfu5.jpg', import.meta.url).href,
        new URL('../assets/images/hanfu6.jpg', import.meta.url).href,
      ],
      currentImageIndex: 0,
      autoPlayInterval: null,
      isScrolled: false,
    }
  },
  methods: {
    nextImage() {
      this.currentImageIndex = (this.currentImageIndex + 1) % this.images.length
    },
    prevImage() {
      this.currentImageIndex = (this.currentImageIndex - 1 + this.images.length) % this.images.length
    },
    setImage(index) {
      this.currentImageIndex = index
    },
    startAutoPlay() {
      this.autoPlayInterval = setInterval(this.nextImage, 5000) // 每5秒切换一次
    },
    stopAutoPlay() {
      if (this.autoPlayInterval) {
        clearInterval(this.autoPlayInterval)
      }
    },
    handleScroll() {
      this.isScrolled = window.scrollY > 50
    },
    goToLogin() {
      this.$router.push('/login')
    }
  },
  mounted() {
    window.addEventListener('scroll', this.handleScroll)
    this.startAutoPlay()
  },
  beforeUnmount() {
    window.removeEventListener('scroll', this.handleScroll)
    this.stopAutoPlay()
  }
}
</script> 